import 'package:json_annotation/json_annotation.dart';
part 'resp_model.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class RespModel<T> {
  @JsonKey(defaultValue: '')
  final String code;
  @JsonKey(defaultValue: '')
  final String message;
  final T? data;

  const RespModel({
    required this.code,
    required this.message,
    this.data,
  });

  factory RespModel.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) =>
      _$RespModelFromJson<T>(json, fromJsonT);

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => _$RespModelToJson<T>(this, toJsonT);
}

@JsonSerializable(genericArgumentFactories: true)
class RespListModel<T> {
  @JsonKey(defaultValue: '')
  final String code;
  @JsonKey(defaultValue: '')
  final String message;
  final List<T>? data;

  const RespListModel({
    required this.code,
    required this.message,
    this.data,
  });

  factory RespListModel.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) =>
      _$RespListModelFromJson<T>(json, fromJsonT);

  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) => _$RespListModelToJson<T>(this, toJsonT);
}
